package com.ljq.software_springboot.softwareprogram.mapper;

import com.ljq.software_springboot.softwareprogram.entity.GroupMessage;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-12-29
 */
@Mapper
public interface GroupMessageMapper extends BaseMapper<GroupMessage> {
    @Select("SELECT gm.id, gm.sender_id, gm.content, gm.timestamp, a.username " +
            "FROM group_message gm " +
            "JOIN account a ON gm.sender_id = a.id " +
            "WHERE gm.group_id = #{groupId} " +
            "ORDER BY gm.timestamp")
    List<GroupMessage> getGroupMessages(@Param("groupId") Integer groupId);

}
